package com.atguigu.flink03;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author Felix
 * @date 2024/2/20
 * 该案例演示了执行模式
 */
public class Flink02_Runtime_M {
    public static void main(String[] args) throws Exception {
        //TODO 1.指定流处理环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //设置执行模式
        //env.setRuntimeMode(RuntimeExecutionMode.BATCH);

        //从指定的网络端口读取数据
        DataStreamSource<String> lineStrDS = env.socketTextStream("hadoop102", 8888);
        lineStrDS.print();

        //提交运行
        env.executeAsync();

        StreamExecutionEnvironment env1 = StreamExecutionEnvironment.getExecutionEnvironment();

        //从指定的网络端口读取数据
        DataStreamSource<String> lineStrDS1 = env1.socketTextStream("hadoop102", 9999);
        lineStrDS1.print();

        //提交运行
        env1.executeAsync();

    }
}
